<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app"></div>
  <script src="./package/vue.js"></script>
  <script>
    Vue.component('parent', {
      data() {
        return {
          msg: '我是神父', 
          childData: ''
        }
      },
      template: `
        <div class="parent">
          <div>我是父组件，收到子组件传递过来的值：{{childData}}</div>
          <child :msg="msg" @getChildMsg="getChildMsg"></child>
        </div>
      `,
      methods: {
        getChildMsg(data) {
          this.childData = data
        }
      }
    })
    Vue.component('child', {
      props: ['msg'],
      data() {
        return {
          
        }
      },
      template: `
        <div class="child">
          <p>我是子组件，收到父组件的值：{{msg}}</p>
          <button @click="getChildMsg">传递值给父组件</button>
        </div>
      `,
      methods: {
        getChildMsg() {
          this.$emit('getChildMsg', '我是神子')
        }
      }
    })
    var app = new Vue({
      el: "#app",
      template: `
        <parent></parent>
      `
    })
  </script>
</body>
</html>